#!/bin/sh

services_file=/etc/services

/bin/echo -n "adding new service(s) ... "
if [ -z "`/bin/grep \"^\(imsp\|sieve\|lmtp\|fud\)\" $services_file`" ] ; then
    /bin/cp $services_file $services_file.cyrus-imap-save
    /bin/sed -i "s/^#\(pop3\)/\1/g" $services_file
    /bin/sed -i "s/^#\(imap2\)/\1/g" $services_file
    /bin/echo -e "\n# start of cyrus-imapd services\nimsp\t\t406/tcp\nsieve\t\t2000/tcp\nlmtp\t\t2003/tcp\nfud\t\t4201/udp\n# end of cyrus-imapd services" >> $services_file
    /bin/echo "ok"
else
    /bin/echo "failed"
fi

/bin/echo "changing permission ... "

/bin/chown mail:mail %OPTWARE_TARGET_PREFIX%/var/lib/imap
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/db
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/log
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/msg
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/proc
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/ptclient
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/socket
/bin/chown -R mail:root %OPTWARE_TARGET_PREFIX%/var/lib/imap/ssl
/bin/chown -R mail:mail %OPTWARE_TARGET_PREFIX%/var/lib/imap/quota
/bin/chown -R mail:mail %OPTWARE_TARGET_PREFIX%/var/lib/imap/sieve
/bin/chown -R mail:mail %OPTWARE_TARGET_PREFIX%/var/lib/imap/user
/bin/chown mail:mail %OPTWARE_TARGET_PREFIX%/var/spool/imap/mail
/bin/chown mail:mail %OPTWARE_TARGET_PREFIX%/var/spool/imap/news
/bin/chown mail:mail %OPTWARE_TARGET_PREFIX%/var/spool/imap/stage.
/bin/chown mail:mail %OPTWARE_TARGET_PREFIX%/var/spool/imap/user

/bin/echo
/bin/echo Please read the man-pages and docs carefully,
/bin/echo -e "\t\$ less %OPTWARE_TARGET_PREFIX%/share/docs/cyrus-imapd/README"
/bin/echo -e "\t\$ man cyrus_master"
/bin/echo -e "\t\$ lynx %OPTWARE_TARGET_PREFIX%/share/docs/cyrus-imapd/html/index.html"
/bin/echo
/bin/echo then configure cyrus-imapd,
/bin/echo -e "\t\$ vi %OPTWARE_TARGET_PREFIX%/etc/cyrus.conf"
/bin/echo -e "\t\$ vi %OPTWARE_TARGET_PREFIX%/etc/imapd.conf"
/bin/echo
/bin/echo and start saslauthd and the server
/bin/echo -e "\t\$ %OPTWARE_TARGET_PREFIX%/etc/init.d/S52saslauthd"
/bin/echo -e "\t\$ %OPTWARE_TARGET_PREFIX%/etc/init.d/S59cyrus-imapd"
/bin/echo
 
